//
//  FSSpecialTopicHomePageCell.m
//  fanshu
//
//  Created by 许海峰 on 16/4/30.
//  Copyright © 2016年 FS. All rights reserved.
//

#import "FSSpecialTopicHomePageCell.h"
#import "FSUserAddAttentionItem.h"
#import "UIImageView+WebCache.h"
@implementation FSSpecialTopicHomePageCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        //头像
        UIImageView *iconView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 20, 20, 20)];
        iconView.image = [UIImage imageNamed:@"icon_notification_follow"];
        [self.contentView addSubview:iconView];
        self.iconView = iconView;
        
        //创建者
        UIButton * builderBtn = [UIButton buttonWithType:UIButtonTypeSystem];
        [builderBtn setTitle:@"M了个M" forState:UIControlStateNormal];
        [builderBtn setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
        builderBtn.titleLabel.font = [UIFont systemFontOfSize:12];
        builderBtn.x = 40;
        builderBtn.y = 20;
        [builderBtn sizeToFit];
        builderBtn.width = 100;
        [self.contentView addSubview:builderBtn];
        self.topic = builderBtn;
        
        //标题
        UILabel *title_Label = [[UILabel alloc] initWithFrame:CGRectMake(10, 50, ScreenWidth - 100, 60)];
        title_Label.text = @"如何拿到200万月薪";
        title_Label.font = [UIFont systemFontOfSize:12];
//        [title_Label sizeToFit];
        title_Label.numberOfLines = 0;
        [self.contentView addSubview:title_Label];
        self.special = title_Label;
        
        //关注数,文章数
        UILabel *countLabel = [[UILabel alloc] init];
        countLabel.x = 10;
        countLabel.y = CGRectGetMaxY(title_Label.frame) + 10;
        countLabel.font = [UIFont systemFontOfSize:12];
        countLabel.text = @"12次阅.8评论.5喜欢";
        [countLabel sizeToFit];
        [self.contentView addSubview:countLabel];

        //文章配图
        UIImageView *pictureView = [[UIImageView alloc] initWithFrame:CGRectMake(ScreenWidth - 85, 60, 80, 60)];
        pictureView.image = [UIImage imageNamed:@"img_notification_guide"];
        [self.contentView addSubview:pictureView];
    }
    return self;
}

- (void)setModel:(FSUserAddAttentionItem *)model{
    _model = model;
    //专题图标
    [self.iconView sd_setImageWithURL:[NSURL URLWithString: model.profile_image]];
    //专题名称
    [self.topic setTitle:model.name forState:UIControlStateNormal];
    
    self.special.text = model.text;
    //发布文章总数
    self.countOfArticle.text = [NSString stringWithFormat:@"%zd篇文章",model.repost];
    //关注人数
    self.countOfAttented.text = [NSString stringWithFormat:@"%zd人关注",model.comment];
//    //关注按钮 状态
//    if(model.ding > model.cai * 15){//已关注
//        self.attentBtn.enabled = NO;
//    }else{//未关注
//        self.attentBtn.enabled = YES;
//    }
    //专题介绍
    self.introduction.text = model.text;
}

@end
